﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using System.Web.Mvc;
using System.Collections.Generic;
using Gman.Entity.Entities;
using Gman.WebApp.ServiceControllers;
using Gman.WebApp.Models;

namespace Gman.WebApp.Models
{
    public class DiagnosticoModel : BaseModel
    {
        public OperacionServiceController service = new OperacionServiceController();

        public ValidationBase Validator { get; set; }
        public List<KeyValuePair<String, String>> ValidationList = new List<KeyValuePair<string, string>>();
        public List<KeyValuePair<String, bool>> PropertyVisibilityList = new List<KeyValuePair<string, bool>>();

        public Guid? ID { get; set; }
        public String Action { get; set; }
        public ToolBarModel ToolBar { get; set; }
        public DiagnosticoBE Diagnostico { get; set; }

        public List<DiagnosticoDetalleModel> DiagnosticoDetalles { get; set; }
        public SelectList Proveedor { get; private set; }
        public SelectList Sede { get; private set; }
        public SelectList Motivo { get; private set; }
        public SelectList PersonalTecnico { get; private set; }

        SedeBE sede = new SedeBE();
        ProveedorBE proveedor = new ProveedorBE();

        public List<DiagnosticoDetalleModel> toDelete { get; set; }

        public DiagnosticoModel()
        {
            Diagnostico = new DiagnosticoBE();
            ID = Guid.NewGuid();

            Proveedor = ListaProveedores();
            Sede = ListaSedes();
            Motivo = ListaMotivos();
            PersonalTecnico = ListaPersonalTecnico();

            DiagnosticoDetalles = new List<DiagnosticoDetalleModel>();
            toDelete = new List<DiagnosticoDetalleModel>();
        }

        public DiagnosticoModel(DiagnosticoBE diagnostico)
        {
            Diagnostico = diagnostico;
            ID = Guid.NewGuid();

            Proveedor = ListaProveedores();
            Sede = ListaSedes();
            Motivo = ListaMotivos();
            PersonalTecnico = ListaPersonalTecnico();

            DiagnosticoDetalles = new List<DiagnosticoDetalleModel>();
            toDelete = new List<DiagnosticoDetalleModel>();
        }



        public SelectList ListaProveedores()
        {
            List<SelectListItem> listItem = new List<SelectListItem>();

            listItem.Add(seleccione);
            listItem.AddRange(new SelectList(service.ListProveedor(proveedor), "IDProveedor", "RazonSProv"));

            return new SelectList(listItem, "Value", "Text");
        }

        public SelectList ListaSedes()
        {
            sede.IDEmp = 1;
            List<SelectListItem> listItem = new List<SelectListItem>();

            listItem.Add(seleccione);
            listItem.AddRange(new SelectList(service.ListarSede(sede), "IDSede", "NomSede"));

            return new SelectList(listItem, "Value", "Text");
        }

       

        public SelectList ListaMotivos()
        {
            List<SelectListItem> list = new List<SelectListItem>();

            list.Add(seleccione);
            list.Add(new SelectListItem() { Text = "Mantenimiento", Value = "1" });
            list.Add(new SelectListItem() { Text = "Correctivo", Value = "2" });
            list.Add(new SelectListItem() { Text = "Preventivo", Value = "3" });

            return new SelectList(list, "Value", "Text");
        }

        public SelectList ListaPersonalTecnico()
        {
            List<SelectListItem> list = new List<SelectListItem>();

            list.Add(seleccione);
            list.Add(new SelectListItem() { Text = "Claudio Pizarro", Value = "1" });
            list.Add(new SelectListItem() { Text = "Juan Perez", Value = "2" });
            list.Add(new SelectListItem() { Text = "Jordi Reyna", Value = "3" });

            return new SelectList(list, "Value", "Text");
        }



    }
}
